package cz.cuni.mff.ufal.volk;

import java.io.File;

/**
 * Auxiliary class that provides some useful static methods.
 *
 * @author Bartłomiej Etenkowski
 */
class Auxiliary {
  /** To make the class "static". */
  private Auxiliary() {
  }

  public static File getLocalResource(File localDirectory, String resource)  {
    // FIXME security issue
    File requestedFile = (new File(localDirectory.getAbsolutePath() + File.separator + resource)).getAbsoluteFile();

    if (requestedFile.isFile()) {
      File current = requestedFile;
      while (current != null) {
        if (current.equals(localDirectory))
          return requestedFile;
        current = current.getParentFile();
      }
      return null;
    } else {
      return null;
    }
  }
}